<?php

namespace App\Http\Middleware;

use App\User;
use Closure;

class CheckUuidMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $uuid = request('user_id');
        if (!$uuid) {
            return response()->json(error('你是谁呢？'));
        }
        $user_id = User::CheckUserUuid($uuid);
        if (!$user_id) {
            return response()->json(error('用户有问题'));
        }
        return $next($request);
    }
}
